//
//  UserTopView.m
//  fp
//
//  Created by xingshuai on 2020/11/10.
//

#import "UserTopView.h"

@interface UserTopView ()

@property (nonatomic, strong) UIImageView *headImg;
@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation UserTopView

-(UIImageView *)headImg {
    if (!_headImg) {
        _headImg = [[UIImageView alloc]init];
        _headImg.image = [UIImage imageNamed:@"def_img"];
        _headImg.layer.borderColor = customColor(78, 117, 255, 1).CGColor;
        _headImg.layer.borderWidth = 2;
        _headImg.layer.cornerRadius = 40;
        _headImg.layer.masksToBounds = YES;
        _headImg.backgroundColor = customColor(239, 243, 255, 1);
    }
    return _headImg;
}

-(UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"这是一个小丸子";
        _nameLabel.textColor = customColor(78, 117, 255, 1);
        _nameLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
    }
    return _nameLabel;
}

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.headImg];
        [self addSubview:self.nameLabel];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(15);
        make.size.mas_offset(CGSizeMake(80, 80));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headImg);
        make.left.equalTo(self.headImg.mas_right).offset(10);
        make.right.equalTo(self).offset(-10);
    }];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
